import React from "react";
import { Canvas, useLoader } from "@react-three/fiber";
import { BufferGeometry, BufferAttribute } from "three";
import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";

const ShowSinglePly: React.FC = () => {
  const ply = useLoader(PLYLoader, "/mesh.ply");

  const geometry = new BufferGeometry();
  geometry.setAttribute(
    "position",
    new BufferAttribute(ply.attributes.position.array, 3),
  );

  return (
    <Canvas>
      <points geometry={geometry}>
        <pointsMaterial size={0.1} color="blue" />
      </points>
    </Canvas>
  );
};
export default ShowSinglePly;
